From: Jonas Dreßler Date: Sat, 5 Nov 2022 21:36:47 +0000 (+0100) Subject: Connect to DnD signals using connectObject() X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~116^2^2~22 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=d1b20f0b38f76037855cdde488ec4fc959d35678;p=gnome-shell.git Connect to DnD signals using connectObject() Currently DnD uses `disconnectAll()` in a `::destroy` signal handler for the drag actor. This is a little weird, as usually the connecting object is in charge of disconnecting as well. Since we have some nice convenience API for this nowadays, use `connectObject()` when connecting to DnD signals in the various draggable actors that we have, which ensures the signal is disconnected as soon as the draggable actors get destroyed. This allows removing the call to `disconnectAll()` in DnD. Part-of: --- diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index c7959f352..0bc8f9ad5 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -1886,10 +1886,11 @@ class AppViewItem extends St.Button { if (isDraggable) { this._draggable = DND.makeDraggable(this, {timeoutThreshold: 200}); - - this._draggable.connect('drag-begin', this._onDragBegin.bind(this)); - this._draggable.connect('drag-cancelled', this._onDragCancelled.bind(this)); - this._draggable.connect('drag-end', this._onDragEnd.bind(this)); + this._draggable.connectObject( + 'drag-begin', this._onDragBegin.bind(this), + 'drag-cancelled', this._onDragCancelled.bind(this), + 'drag-end', this._onDragEnd.bind(this), + this); } this._otherIconIsHovering = false; diff --git a/js/ui/dnd.js b/js/ui/dnd.js index 63a279b4b..c41e0f8ca 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -119,7 +119,6 @@ class _Draggable extends Signals.EventEmitter { if (this._dragState === DragState.DRAGGING && this._dragCancellable) this._cancelDrag(global.get_current_time()); - this.disconnectAll(); }); this._onEventId = null; this._touchSequence = null; diff --git a/js/ui/windowPreview.js b/js/ui/windowPreview.js index 95a2276ca..3bc04187e 100644 --- a/js/ui/windowPreview.js +++ b/js/ui/windowPreview.js @@ -108,9 +108,11 @@ export const WindowPreview = GObject.registerClass({ dragActorMaxSize: WINDOW_DND_SIZE, dragActorOpacity: DRAGGING_WINDOW_OPACITY, }); - this._draggable.connect('drag-begin', this._onDragBegin.bind(this)); - this._draggable.connect('drag-cancelled', this._onDragCancelled.bind(this)); - this._draggable.connect('drag-end', this._onDragEnd.bind(this)); + this._draggable.connectObject( + 'drag-begin', this._onDragBegin.bind(this), + 'drag-cancelled', this._onDragCancelled.bind(this), + 'drag-end', this._onDragEnd.bind(this), + this); this.inDrag = false; let clickAction = new Clutter.ClickAction(); diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js index a484dce12..d029563a7 100644 --- a/js/ui/workspaceThumbnail.js +++ b/js/ui/workspaceThumbnail.js @@ -86,9 +86,11 @@ export const WindowClone = GObject.registerClass({ dragActorMaxSize: Workspace.WINDOW_DND_SIZE, dragActorOpacity: Workspace.DRAGGING_WINDOW_OPACITY, }); - this._draggable.connect('drag-begin', this._onDragBegin.bind(this)); - this._draggable.connect('drag-cancelled', this._onDragCancelled.bind(this)); - this._draggable.connect('drag-end', this._onDragEnd.bind(this)); + this._draggable.connectObject( + 'drag-begin', this._onDragBegin.bind(this), + 'drag-cancelled', this._onDragCancelled.bind(this), + 'drag-end', this._onDragEnd.bind(this), + this); this.inDrag = false; const clickAction = new Clutter.ClickAction();